package com.offices.subscribe.dto.message.newsmessage;

import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.offices.subscribe.dto.message.BaseMessage;
import lombok.Data;
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.Map;

@Data
public class NewsMessage extends BaseMessage {

    @JacksonXmlProperty(localName = "ArticleCount")
    private Integer articleCount;
    @JacksonXmlElementWrapper(localName = "Articles")
    @JacksonXmlProperty(localName = "item")
    private List<Articles> articles;

    public NewsMessage(Map<String, String> request, @NotNull List<Articles> articles) {
        super(request);
        this.setMsgType("news");
        this.articles = articles;
//      计算图文消息的长度并赋值给articleCount
        this.articleCount = articles.size();

    }
}
